﻿using PirateShare;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Diagnostics;

namespace PirateShareTests
{
    
    /// <summary>
    ///Unit tests for CryptoHelper
    ///</summary>
    [TestClass()]
    public class CryptoHelperTest
    {

        // FIXME: get path to output dir
        private string testpath = @"C:\Users\Maverick\Documents\Visual Studio 2010\Projects\PirateShare\PirateShareTests\bin\Debug\";

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        /// <summary>
        ///A test for FileHash
        ///</summary>
        [TestMethod()]
        public void FileHashTest()
        {
            string fileName = "TextFile1.txt";
            string expected = "46b45469464f981f479d2e9f325301f3de305a12"; // "Hello World!"
            string actual = CryptoHelper.FileHash(testpath + fileName);
            if (!string.IsNullOrEmpty(expected)) {
                Assert.AreEqual(expected, actual);
            }
            else
            {
                Assert.Inconclusive(string.Format("FileHash(\"{0}\") returned \"{1}\"", fileName, actual)); 
            }
        }
    }
}
